package com.mike.action;

import java.util.Map;

import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

import cn.dsna.util.images.ValidateCode;

@Controller("codeAction")
public class codeAction extends ActionSupport implements ServletResponseAware,ServletRequestAware{

	private javax.servlet.http.HttpServletResponse response;
	@Override
	public void setServletResponse(HttpServletResponse response) {
		
		this.response = response;
		
	}
	private javax.servlet.http.HttpServletRequest request;
	@Override
	public void setServletRequest(HttpServletRequest request) {
		
		this.request = request;
	}
	
	
	@Override
	public String execute() throws Exception {
		ValidateCode code = new ValidateCode(100,30,4,10);
		String str = code.getCode();//获取验证码的数据  
		HttpSession session = request.getSession();
		session.setAttribute("code", str);
		//生成验证码
		code.write(response.getOutputStream());
		return super.execute();
	}

	

	
	

	
}
